Purple, your script is still not correct. Now that I can finally debug again, here's the real scoop on how the intermission event works:
When the fraglimit (ffa) or roundlimit (obj / dm) has been reached, the intermission local.type variable is set to 0. However, the server may or may not call another map depending on the config after this intermission. If the server.cfg is setup to run a different map, local.type will be set to 1 right before the map is called. If the server is setup to play the same map again and again (only one map in rotation), then a restart is called which again calls intermission and local.type is set to 2 before the first round of the same map begins. Rcon restart will also result in local.type being equal to 2.
So the real documentation should read:
Code:
/*
Intermission Event (Runs after fraglimit or roundlimit has been reached, when a new map is called either by a config or rcon, and when a map restarts in between rounds or rcon restart command is issued):
// There are many types of intermission which occur
// When the intermission event is threaded, the type of intermission depends on what is going on in the server.
// Depending on the circumstances, the type of intermission is stored in a variable called local.type which can be set to integer values of 0, 1, and 2 ONLY
local.type - type of server intermission
// local.type values and what they each mean
0 = Player intermission screen (happens when map's fraglimit / roundlimit has been reached)
1 = Map change (happens after using the following rcon commands: map and gamemap) && (happens when the server is switching to a DIFFERENT MAP)
2 = Map restart (happens after using the rcon restart command from console) && (happens in between rounds) && (happens during short intermissions when a round [NOT THE FINAL ROUND BEFORE FRAGLIMIT] is over and player scores are shown real quick for the round) && (happens directly after the final player intermission screen [when local.type is set to 0] IF AND ONLY IF THE SAME MAP IS GOING TO BE LOADED or REPLAYED DUE TO ONLY ONE MAP BEING IN THE MAP LIST [ example: sv_maplist "obj/obj_team2" ]
*/
I hope that makes sense. An example of how to use the intermission event properly is shown in the below code snippet.
The script should look like:
Code:
main:
// Set debug mode
local.debug = 0;
local.inScrim = int(getcvar(inscrim))
if(local.debug == 1){
println "Debug CVAR Print"
println local.inScrim
println level.elgboton
}
if(local.inScrim == 1){
// Set teamswitch delay
teamswitchdelay .1
if(int(getcvar("elgbot")) == 0){
// Unregister events
if(level.unregSwap == NIL || level.unregSwap == 0){
level.unregSwap = 1;
if(local.debug == 1){
local.unreg2 = unregisterev "intermission"
local.unreg3 = unregisterev "connected"
// Print out the results
println "Event Un-Registration Debug Print"
println local.unreg2
println local.unreg3
}
}
// Register events
local.connectme = registerev "connected" teamswap/swap.scr::connected
local.intermission = registerev "intermission" teamswap/swap.scr::intermission
// Print out results
if(local.debug == 1){
println "Event Registration Debug Print"
println local.connectme
println local.intermission
}
}
}
//Check if players were swapped last round, if so, reset the cvars
if(getcvar swapped == "1") {
setcvar swap "0"
setcvar swapped "0"
}
end
connected local.player:
if(getcvar swap){
println "In connected event and swap is:"
println (getcvar swap)
}
if(getcvar swap == "1" && int(getcvar(inscrim)) == 1) {
if(local.player.dmteam == "axis") {
setcvar swapped "1" //set a cvar so that we don't swap again next round.
local.player join_team allies
}
else {
if(local.player.dmteam == "allies") {
setcvar swapped "1" //set a cvar so that we don't swap again next round.
local.player join_team axis
}
}
}
end
intermission local.type:
println local.type
if(local.type == 0){
setcvar swap "1"
println "intermission event hit... setting swap cvar up"
}else if(local.type == 1){
setcvar swap "1"
println "intermission event hit... setting swap cvar up"
}
end
The reason why it didn't work before is because in the log:
Code:
intermission local.type = 0
intermission event hit... setting swap cvar up
intermission local.type = 2
...
first round of same map begins
connected event is called but swap is set to 0 instead of 1 because intermission was called twice with the last time having local.type set to 2 where we reset swap to 0 in the original script.
I tested it, and it's working perfectly now!